﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 类和属性
{
    class Book
    {
        //3.定义一个图书类，存放图书的编号、书名、价格、出版社、作者信息；
        //  对价格进行赋值限制，小于0价格，赋值为0
        //  在图书类中定义一个方法输出图书信息；
        //  在主方法实例化对象，赋值并输出
        public int bookID { get; set; }
        public string bookName { get; set; }
        public int Price { get; set; }
        public string Press { get; set; }
        public string Author { get; set; }

        public Book(int bookID, string bookName, int price, string press, string author)
        {
            this.bookID = bookID;
            this.bookName = bookName;
            Price = price;
            Press = press;
            Author = author;
        }

        public Book()
        {
        }

        public void assignment()
        {
            Console.Write("请输入书的编号：");
            this.bookID = int.Parse(Console.ReadLine());
            Console.Write("请输入书名：");
            this.bookName = Console.ReadLine();
            Console.Write("请输入书的价格：");
            this.Price = int.Parse(Console.ReadLine());
            if (this.Price < 0)
            {
                this.Price = 0;
            }
            Console.Write("请输入书的出版社：");
            this.Press = Console.ReadLine();
            Console.Write("请输入书作者的信息：");
            this.Author = Console.ReadLine();
        }
        public void print() 
        {
            Console.WriteLine($"编号：{this.bookID}    书名：{this.bookName}   价格：{this.Price}￥   出版社：{this.Press}   作者信息：{this.Author}。");
        }
    }
}
